feat(nodes): add Docker API backend#394
Conversation
runleveldev
left a comment
There was a problem hiding this comment.
The UI displays "Creds missing" for Docker nodes
Running our default templates fail since they use SystemD. Similar to how Proxmox checks for "application containers" and make the nessecary adjustments, this needs to check for "system containers" and make the nessacary adjustments (such as setting privileged: true)
7a542e3b9e12 ghcr.io/mieweb/opensource-server/base:latest "/sbin/init" 19 seconds ago Exited (255) 17 seconds ago hollow-urban-otter
| async createLxc(node, options = {}) { | ||
| if (!this.lastPulledImage) { | ||
| throw new Error('No Docker image has been pulled for this create operation'); | ||
| } |
There was a problem hiding this comment.
This is an unnecessary check. Images might be cached for example.
There was a problem hiding this comment.
Fixed in b652af3 — fix(docker): allow cached images during create.
There was a problem hiding this comment.
@ArshSSandhu please drop the commit that fixed this. I misunderstood the behavior of the image parsing and given the existing behavior this.lastPulledImage should always be set during this operation and docker image caching would already apply properly based on image reference.
|
The Docker credential badge was fixed in The systemd/default template handling was fixed in I pushed the requested review fixes as separate commits so each item is easier to inspect. Testing run:
I replied on the individual threads with the commit that addresses each item. I left the Docker real container ID thread unresolved because |
| }, | ||
| ] | ||
| : []; | ||
| } catch (err) { |
There was a problem hiding this comment.
This is swallowing all errors, not just errors indicating that the nodes is not part of a swarm. This could cause a swarm-included node to improperly present as a not swarm node due to communication failures rather than throwing as expected.
| async createLxc(node, options = {}) { | ||
| if (!this.lastPulledImage) { | ||
| throw new Error('No Docker image has been pulled for this create operation'); | ||
| } |
There was a problem hiding this comment.
@ArshSSandhu please drop the commit that fixed this. I misunderstood the behavior of the image parsing and given the existing behavior this.lastPulledImage should always be set during this operation and docker image caching would already apply properly based on image reference.
| image.includes('/base:') || | ||
| image.includes('/base@') || | ||
| image.endsWith('/base') |
There was a problem hiding this comment.
This is a bad hueristic. Stick with what you've got based on the entrypoint.
| function validateNodeInput({ nodeType, apiUrl }) { | ||
| const type = normalizeNodeType(nodeType); | ||
|
|
||
| if (!['proxmox', 'docker', 'dummy'].includes(type)) { |
There was a problem hiding this comment.
Make sure the OpenAPI spec is updated as well.
Summary
Closes #375.
This PR adds support for Docker-backed nodes by introducing a new
DockerApiimplementation that follows the existing Node API contract used byProxmoxApiandDummyApi.Changes include:
DockerApiusing Docker Engine's native HTTP API throughaxiosunix:///var/run/docker.socktcp://host:2375http://...https://...Node.api()to dispatch toDockerApiwhennodeType === "docker"node.hasApiAccess()Node.provisionableWhere(...)nodeTypesupport to node API serialization, create, and update routesunix:///var/run/docker.sockin the frontend formRelated Issue
Closes #375
Testing
Tested locally with the following checks:
Ran backend syntax checks successfully:
Ran frontend type-check successfully:
Ran whitespace checks successfully:
Tested
DockerApidirectly against local Docker using:Verified direct Docker lifecycle flow:
nginx:latestVerified the UI can create a Docker node with:
Attempted full UI container creation with
nginx:latest. The job selected the Docker node and Docker image path correctly, but failed with:This appears to be a local runtime/socket-mount limitation because the Manager runtime does not currently have the host Docker socket mounted. The
DockerApiitself was verified successfully through the direct lifecycle test above.Screenshots
Docker node form
Docker node created
Breaking Changes
None known.
Notes
Full end-to-end Docker provisioning from the UI requires the Manager runtime to have access to the configured Docker host. For local socket usage,
/var/run/docker.sockmust be mounted or otherwise reachable from the process running Manager.